home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
language
/
gemfsc18.lzh
/
AESSRC18.LZH
/
AESFUNCS
/
FRMPROGR.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-04-05
|
15KB
|
395 lines
/*************************************************************************
* FRMDSMEN.C - The frm_dsmenu() routine.
*************************************************************************/
#include <stdarg.h>
#include "gemfast.h"
#include "frmtypes.h"
#ifndef NULL
#define NULL 0L
#endif
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif
/*-------------------------------------------------------------------------
* The tedinfos for the dialog body text.
* We have to use our own tedinfos instead of sharing the common array
* of them in FRMNLDSU.C, because we're non-modal, and other users of
* the common array can be invoked while the progress display is up.
*-----------------------------------------------------------------------*/
static TEDINFO local_tedinfos[] = {
{NULL, NULL, NULL, 3, 6, 0, 0x11F0, 0, 0, 1, 1},
{NULL, NULL, NULL, 3, 6, 0, 0x11F0, 0, 0, 1, 1},
{NULL, NULL, NULL, 3, 6, 0, 0x11F0, 0, 0, 1, 1},
{NULL, NULL, NULL, 3, 6, 0, 0x11F0, 0, 0, 1, 1},
{NULL, NULL, NULL, 3, 6, 0, 0x11F0, 0, 0, 1, 1},
{NULL, NULL, NULL, 3, 6, 0, 0x11F0, 0, 0, 1, 1},
{NULL, NULL, NULL, 3, 6, 0, 0x11F0, 0, 0, 1, 1},
{NULL, NULL, NULL, 3, 6, 0, 0x11F0, 0, 0, 1, 1},
{NULL, NULL, NULL, 3, 6, 0, 0x11F0, 0, 0, 1, 1},
{NULL, NULL, NULL, 3, 6, 0, 0x11F0, 0, 0, 1, 1}
};
/*------------------------------------------------------------------------
* the dialog tree...
*-----------------------------------------------------------------------*/
#define OUTLINED_BOX_SPEC 0x00021100L
#define SHADOWED_BOX_SPEC 0x00FF1100L
static OBJECT progress_dialog[] = {
{ -1, 1, 13, G_BOX, NONE, OUTLINED, 0x00021100L, 0x0000, 0x0000, 0x0001, 0x0000},
{ 12, 2, 11, G_IBOX, NONE, NORMAL, 0x00001100L, 0x0001, 0x0000, 0x0001, 0x0000},
{ 3, -1, -1, G_BOXTEXT, NONE, NORMAL, 0L, 0x0000, 0x0001, 0x0001, 0x0001},
{ 4, -1, -1, G_BOXTEXT, NONE, NORMAL, 0L, 0x0000, 0x0002, 0x0001, 0x0001},
{ 5, -1, -1, G_BOXTEXT, NONE, NORMAL, 0L, 0x0000, 0x0003, 0x0001, 0x0001},
{ 6, -1, -1, G_BOXTEXT, NONE, NORMAL, 0L, 0x0000, 0x0004, 0x0001, 0x0001},
{ 7, -1, -1, G_BOXTEXT, NONE, NORMAL, 0L, 0x0000, 0x0005, 0x0001, 0x0001},
{ 8, -1, -1, G_BOXTEXT, NONE, NORMAL, 0L, 0x0000, 0x0006, 0x0001, 0x0001},
{ 9, -1, -1, G_BOXTEXT, NONE, NORMAL, 0L, 0x0000, 0x0007, 0x0001, 0x0001},
{ 10, -1, -1, G_BOXTEXT, NONE, NORMAL, 0L, 0x0000, 0x0008, 0x0001, 0x0001},
{ 11, -1, -1, G_BOXTEXT, NONE, NORMAL, 0L, 0x0000, 0x0009, 0x0001, 0x0001},
{ 1, -1, -1, G_BOXTEXT, NONE, NORMAL, 0L, 0x0000, 0x000A, 0x0001, 0x0001},
{ 13, -1, -1, G_BOX, NONE, NORMAL, 0x00FF1131L, 0x0001, 0x0000, 0x0001, 0x0001},
{ 0, -1, -1, G_BUTTON, 0x0027, NORMAL, 0L, 0x0000, 0x0000, 0x0001, 0x0001}
};
#define TEXT_BOX 1
#define FIRST_TEXT_LINE 2
#define THERMO_BAR 12
#define EXIT_BUTTON 13
#define MAXLINES Array_els(local_tedinfos)
/*------------------------------------------------------------------------
* misc static data...
*-----------------------------------------------------------------------*/
static FormControl progress_ctl;
static int initdone = FALSE;
static char *formatted_text;
static int lastline;
static int oldmouse;
/*------------------------------------------------------------------------
* dummy_do - The form_do() handler when the dialog isn't abortable.
*-----------------------------------------------------------------------*/
static int dummy_do(ctl)
FormControl *ctl;
{
return NO_OBJECT;
}
/*------------------------------------------------------------------------
* watchbutton_do - The form_do() handler to watch the abort button.
* This is a non-modal handler. It checks the keyboard and mouse button,
* and if neither is active, it returns NO_OBJECT.
*-----------------------------------------------------------------------*/
static int watchbutton_do(ctl)
FormControl *ctl;
{
int obj;
int mouseobj;
XMULTI xm;
xm.mflags = MU_BUTTON | MU_KEYBD | MU_TIMER;
xm.mbstate = 1;
xm.mbmask = 1;
xm.mbclicks = 1;
xm.mtlocount = 1;
xm.mthicount = 0;
obj = NO_OBJECT;
evnx_multi(&xm);
if ((xm.mwhich & MU_KEYBD)
&& (xm.mkreturn & 0x00FF) == '\r') {
obj = EXIT_BUTTON;
obj_stchange(ctl->ptree, obj, SELECTED, OBJ_CLIPDRAW, ctl->pboundrect);
}
if (xm.mwhich & MU_BUTTON) {
mouseobj = objc_find(ctl->ptree, ROOT, MAX_DEPTH, xm.mmox, xm.mmoy);
if (mouseobj == NO_OBJECT) {
gemdos(2, 7); // ding!
} else if (mouseobj == EXIT_BUTTON) {
if (graf_watchbox(ctl->ptree, EXIT_BUTTON, SELECTED, NORMAL)) {
obj = EXIT_BUTTON;
}
} else if (mouseobj == ctl->moverobj) {
obj = mouseobj;
}
}
return obj;
}
/*------------------------------------------------------------------------
* setup_dialog - Construct the dynamic dialog, paint it.
*-----------------------------------------------------------------------*/
static int setup_dialog(options, increments, button, fmt, args)
long options;
int increments;
char *button;
char *fmt;
va_list args;
{
int status;
int numlines;
int numbuttons;
int maxwidth;
int btnwidth;
int cumulative_height;
int wchar = gl_wchar;
int hchar2 = gl_hchar * 2;
char *strptrs[MAXLINES+1];
char *strpatches[MAXLINES+1];
register OBJECT *ptree = progress_dialog;
/*--------------------------------------------------------------------
* do one-time init, validate parms, merge in default options.
*-------------------------------------------------------------------*/
if (!initdone) {
initdone = TRUE;
rsc_treefix(ptree);
if (0 != (status = obj_mkthermo(ptree, THERMO_BAR, 1))) {
return status;
}
}
if (progress_ctl.ptree != NULL) {
return -36;
}
if (increments >= gl_rwdesk.g_w) {
return -64;
}
if (!(options & FRM_NODEFAULTS)) {
options |= _FrmDefaults | (FRM_DEFAULT_DYNOPT & ~FRM_MOUSEARROW);
}
options |= FRM_MANDATORY_DYNOPT;
/*--------------------------------------------------------------------
* if a button was specified, its string is the initial maxwidth.
*-------------------------------------------------------------------*/
if (button == NULL) {
maxwidth = btnwidth = 0;
} else {
maxwidth = btnwidth = strlen(button) + 2;
}
/*--------------------------------------------------------------------
* format the text and load it into the dialog objects.
* save a pointer to the string pointer for the last text line.
* this lets easily change the last line of text during an update.
*-------------------------------------------------------------------*/
formatted_text = _FrmVFormat(fmt, args, NULL);
_FrmNL2DS(formatted_text, strptrs, strpatches, MAXLINES);
numlines = _FrmDS2Obj(strptrs, &ptree[FIRST_TEXT_LINE], local_tedinfos,
&maxwidth, MAXLINES);
lastline = TEXT_BOX + numlines;
/*--------------------------------------------------------------------
* from this point on, widths are pixels, no